
<?php $GLOBALS['sys_version'] = ''; //置为空，使各个版本中，Combinator生成的文件名保持移植
 ?>

{{$this->Combinator->css(array('135open.css'))}}

<script>
var BASEURL = "{{substr(Router::url('/',true),0,-1)}}";
</script>
<style>
#content-priview ul {margin:0 0;padding-left: 30px;}
#content-priview * {font-family:"Helvetica Neue",Helvetica,"Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;font-size: 16px;}
#content-priview * {max-width: 100%!important;margin:0;padding:0;font-style:normal;box-sizing: border-box!important;-webkit-box-sizing: border-box!important;word-wrap: break-word!important;}
#content-priview p{clear:both;margin:0 0;font-size:16px;min-height:1em;white-space: normal;}
#content-priview img{*zoom:1;max-width:100%;*max-width:96%;height:auto !important;}
#content-priview iframe{width:301px !important;border:0;background-color:none;}
#content-priview iframe,#content-priview .video_iframe {background-color: #000000;width: 100% !important;position: static;}
#content-priview blockquote{margin:0;padding-left:10px;border-left:3px solid #DBDBDB;}

</style>
<div class="container">	
	<div class="row">		
		<div class="col-md-9" style="display: block;">
			{{if !empty($_POST)}}
			<div class="ui-portlet-header">
			      <span class="title">提交内容预览：</span>            
			</div>
			<table class="table">
				<tr><td>标题</td><td>{{$_POST['title']}}</td></tr>
				<tr><td>摘要</td><td>{{$_POST['summary']}}</td></tr>
				<tr><td>内容</td><td><section id="content-priview" style="max-width:500px;margin:0 auto;">{{$_POST['content']}}</section></td></tr>
			</table>
			{{/if}}
	<br/>
		<div class="ui-portlet-header">
		      <span class="title">编辑器插件整合样例：</span>            
		</div>
		<form action="" class='form-horizontal' method="post">
			<div class="form-group">
				<label class="col-sm-3 control-label">标题</label>
				<div class="col-sm-9 controls">
					<input class='form-control' value="业务系统内嵌135编辑器" name="title" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">摘要</label>
				<div class="col-sm-9 controls">
					<textarea class='form-control' name="summary" col="90" rows="2">无缝集成，内容通过表单提交到业务系统</textarea>
				</div>
			</div>
 			<script id="WxMsgContent" name="content" style="width:845px;min-width:845px;" type="text/plain"><ul class=" list-paddingleft-2" style="list-style-type: disc;">
				<li>编辑器所在区域将替换原业务系统的内容编辑输入区域</li>
				<li>系统整合只需要修改几行前端JS代码，详见“企业插件调用说明”</li>
				<li>上传图片将保存到业务系统服务器，而不是保存到135</li>
				<li>付费获取Appkey后，同步使用135编辑器 样式中心，最新样式想用就用，免去公司技术团队维护成本</li>
				<li>版本更新后，可免费升级</li>
			</ul>
			</script>
 			
 			<div class="form-group" style="margin-top:10px;">
				<label class="col-sm-3 control-label">&nbsp;&nbsp;&nbsp;</label>
				<div class="col-sm-9 controls">
					<input type="submit" value="提交" class="btn btn-primary">
				</div>
			</div>
 		</form>
		<br/>
			
		
		<div class="tab-content">
		 	<div id="category-content" class="ui-portlet clearfix">
		 		<div class="ui-portlet-header">
				      <span class="title">135编辑器企业插件</span>            
				</div>
				<div class="Content-body">
					<?php echo $Category['Category']['content']; ?>
				</div>
				<br/>
				
			</div>
		</div>
	</div>
<?php  
if($Category['Category']['left']+1 == $Category['Category']['right']) {
	$cateLeftMenu = $this->Section->getLeftMenu('Category',array('parent_id'=> $Category['Category']['parent_id'],'selectedid'=>$current_cateid)); 
}
else{
	$cateLeftMenu = $this->Section->getLeftMenu('Category',array('parent_id'=> $Category['Category']['id'],'selectedid'=>$current_cateid)); 
}
$leftMenuText = trim(strip_tags($cateLeftMenu));
?>
		<div class="col-md-3">
			<portlet  title="{{$Category['Category']['name']}}">{{$cateLeftMenu}}</portlet>
		</div>
	</div>
</div>

<?php 
echo $this->Html->script('/js/ueditor/ueditor.plugin.config.js'); //ueditor配置文件引用网址必须与本站点域名相同。否则上传文件等弹出的窗口都为跨域编辑，不可用。

$token = 'PzEGfMGyjfn2FtSYnmm6hrKQ6G6twkwx';
$ecrypt = 'XmhHa6tJ5nwmSzfkktQAaejxB6NcEJhjQmTXzRnAHJ7x';
$ts = time();
$sign = md5($token.$ecrypt.$ts);
if(!isset($_GET['v'])) { $_GET['v'] = 'page';}

?>

{{if defined('IS_LOCALHOST') || Configure::read('debug') }}
	{{if $_GET['debug']}}
		<script type="text/javascript" charset="utf-8" src="/ueditor_src/editor_api.js"> </script>
	{{else}}
		<script src="{{Router::url('/js/ueditor/ueditor.all.min.js')}}"></script>
	{{/if}}
	
{{if $_REQUEST['code']=='gbk'}}
		<?PHP echo $this->Combinator->script(array(
	'ueditor/lang/zh-cn/zh-cn-gbk.js',
	'jquery/jquery.cookie.js','jquery/jquery.mousewheel.min.js',
	'tinycolor-min.js',
	'135editor.js','metro-ui/slider.js',
	'ueditor/135open.js',
	'colorPicker.all.min.js','jqColorPicker.js','jquery/jquery.lazyload.js',
	)); ?>
{{else}}
		<?PHP echo $this->Combinator->script(array(
	'ueditor/lang/zh-cn/zh-cn.js',
	'jquery/jquery.cookie.js','jquery/jquery.mousewheel.min.js',
	'tinycolor-min.js',
	'135editor.js','metro-ui/slider.js',
	'ueditor/135open.js',
	'colorPicker.all.min.js','jqColorPicker.js','jquery/jquery.lazyload.js',
	)); ?>
{{/if}}
	
	
	

{{else}}

	<script src="//static.135editor.com/js/ueditor/ueditor.all.min.js"></script>
	{{if $_GET['v']}}
		<script src="//static.135editor.com/open/a92d301d77.js"></script>
	{{else}}
		<script src="//static.135editor.com/open/v1/a92d301d77.js"></script>
	{{/if}}

{{/if}}
<?PHP  
$appkey = $_REQUEST['appkey'] ?  $_REQUEST['appkey'] : '566d34e0-4bac-443b-8a80-37f89fde689a';
//&token={{$token}}&ts={{$ts}}&sign={{$sign}}
?>

<script>

current_editor = UE.getEditor('WxMsgContent',{
	initialFrameHeight:480,
	style_url : '/editor_styles/open?inajax=1&v={{$_GET['v']}}&appkey={{$appkey}}',
	style_width: 380,
    plat_host:'www.135editor.com',
	appkey:'{{$appkey}}',
	zIndex : 1000,
	page_url : '/editor_styles/open_styles?inajax=1&appkey={{$appkey}}',
	
	{{if strpos($_GET['v'],'page') !== false}}pageLoad:true,{{/if}}
	open_editor:true,
	focus:true,
	enableContextMenu: false,
	focusInEnd:true
});
/*
{{if !empty($_SESSION['Auth']['Staff']) }}

{{else}}
	{{if $_GET['v']}}
		current_editor = UE.getEditor('WxMsgContent',{
			initialFrameHeight:600,
			style_url : '/editor_styles/open?inajax=1&v={{$_GET['v']}}',
			style_width:'460'
		});
	{{else}}	
		current_editor = UE.getEditor('WxMsgContent',{
			initialFrameHeight:600,
			style_url : '/editor_styles/open?inajax=1',
			style_width:'460'
		});
	{{/if}}
{{/if}}
*/

$(function(){

	$(document).on('click','#image-list .appmsg',function(){
		var src = $(this).find('img:first').attr('src');
		insertHtml("<img src=\""+src+"\">"); 
	})

	$(document).on('click','#tab-tpl-trigger',function(){ // 系统及收藏模板加载
		if($('#editor-tpls-list').html()==""){
			$('#editor-tpls-list').html('<img src="/img/ajax/circle_ball.gif"> 正在加载').load('{{$this->Html->url("/editor_styles/myTemplates?suffix=-1")}} #tpl-tab-content',function(){
				
				function favor_template_loaded(){
					
					$('#editor-tpls-list').find('.col-md-3').removeClass('col-md-3').addClass('col-md-6');
					
					$('#favorite-tpl-list-1 .pagelink a').click(function(){
						
						$('#favorite-tpl-list-1').load(this.href,function(){
							favor_template_loaded();
						});
						return false;
					});
				}
				
				favor_template_loaded();
				
				/*if( $('#personal-tpl-list-1').find('.editor-style-content').size() ==0 ){
					$('#personal-tpl-list-li').remove();
				}*/
				$('#editor-tpls-navtab a:first').tab('show');				
			})
		}		
	})

	/*插入模板 */
	$(document).on('click','#tpl-tab-content .insert-tpl-content,#tpl-tab-content .editor-style-content',function(){ //选中模板后设置编辑器的内容	
		var tid = $(this).data('id');
		var obj = $('#template-'+tid);
		
		obj.contents().filter(function() {
			return this.nodeType === 3 && $.trim($(this).text()) == "";
		}).remove();
		obj.find('p').each(function(){
			if($.trim($(this).html())=="&nbsp;") {
				$(this).html('<br/>');
			}
		});
		
		setEditorHtml(obj.html());
		
		var id = parseInt(obj.data('id'));
		
		if(id > 0){
			$('#template_id').val(id);
			$('#auto_cover_tpl').removeClass('hidden');
		}
		else{
			$('#template_id').val('');
			$('#auto_cover_tpl').addClass('hidden');
		}
		
		$('#template_name').val(obj.data('name'));
		$('#dialog-template-name').val(obj.data('name'));
		//$('#feedsModal').modal('hide');
	});

		
});

</script>